%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/include-all-archived"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[42]<br />ᐳ: 10, 11, 50, 52, 53, 12, 14, 27<br />2: PgSelectInlineApply[46]<br />3: PgSelect[9]<br />ᐳ: Access[47]<br />4: PgSelectRows[15]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 47<br /><br />ROOT __Item{1}ᐸ15ᐳ[16]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 47, 16<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[17]<br />1: <br />ᐳ: 18, 48, 49<br />2: PgSelectRows[28]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 49<br /><br />ROOT __Item{3}ᐸ28ᐳ[29]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 30, 43<br /><br />ROOT PgSelectSingle{3}ᐸmessagesᐳ[30]<br />1: <br />ᐳ: 31, 44, 45<br />2: PgSelectRows[38]<br />ᐳ: First[37], PgSelectSingle[39]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 39<br /><br />ROOT PgSelectSingle{4}ᐸusersᐳ[39]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5

    %% plan dependencies
    PgSelect9[["PgSelect[9∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Constantᐸ2ᐳ[50]"]]:::plan
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda14{{"Lambda[14∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'YES' ]ᐳ[52]"}}:::plan
    PgSelectInlineApply46["PgSelectInlineApply[46∈0] ➊<br />More deps:<br />- Constantᐸ2ᐳ[50]"]:::plan
    Object12 & Lambda14 & PgSelectInlineApply46 --> PgSelect9
    Lambda27{{"Lambda[27∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[53]"}}:::plan
    PgSelectInlineApply42["PgSelectInlineApply[42∈0] ➊"]:::plan
    Lambda27 & PgSelectInlineApply42 --> PgSelectInlineApply46
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    PgSelectRows15[["PgSelectRows[15∈0] ➊"]]:::plan
    PgSelect9 --> PgSelectRows15
    Access47{{"Access[47∈0] ➊<br />ᐸ9.m.subqueryDetailsFor20ᐳ"}}:::plan
    PgSelect9 --> Access47
    __Item16[/"__Item[16∈1]<br />ᐸ15ᐳ"\]:::itemplan
    PgSelectRows15 ==> __Item16
    PgSelectSingle17{{"PgSelectSingle[17∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item16 --> PgSelectSingle17
    List48{{"List[48∈2]<br />ᐸ47,16ᐳ"}}:::plan
    Access47 & __Item16 --> List48
    PgClassExpression18{{"PgClassExpression[18∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle17 --> PgClassExpression18
    PgSelectRows28[["PgSelectRows[28∈2]"]]:::plan
    Lambda49{{"Lambda[49∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda49 --> PgSelectRows28
    List48 --> Lambda49
    __Item29[/"__Item[29∈3]<br />ᐸ28ᐳ"\]:::itemplan
    PgSelectRows28 ==> __Item29
    PgSelectSingle30{{"PgSelectSingle[30∈3]<br />ᐸmessagesᐳ"}}:::plan
    __Item29 --> PgSelectSingle30
    Access43{{"Access[43∈3]<br />ᐸ49.m.joinDetailsFor33ᐳ"}}:::plan
    Lambda49 --> Access43
    List44{{"List[44∈4]<br />ᐸ43,30ᐳ"}}:::plan
    Access43 & PgSelectSingle30 --> List44
    PgClassExpression31{{"PgClassExpression[31∈4]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle30 --> PgClassExpression31
    First37{{"First[37∈4]"}}:::plan
    PgSelectRows38[["PgSelectRows[38∈4]"]]:::plan
    PgSelectRows38 --> First37
    Lambda45{{"Lambda[45∈4]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda45 --> PgSelectRows38
    PgSelectSingle39{{"PgSelectSingle[39∈4]<br />ᐸusersᐳ"}}:::plan
    First37 --> PgSelectSingle39
    List44 --> Lambda45
    PgClassExpression40{{"PgClassExpression[40∈5]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression40
    PgClassExpression41{{"PgClassExpression[41∈5]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression40 o--o PgClassExpression41

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect9,Access10,Access11,Object12,Lambda14,PgSelectRows15,Lambda27,PgSelectInlineApply42,PgSelectInlineApply46,Access47 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item16,PgSelectSingle17 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression18,PgSelectRows28,List48,Lambda49 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item29,PgSelectSingle30,Access43 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression31,First37,PgSelectRows38,PgSelectSingle39,List44,Lambda45 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression40,PgClassExpression41 bucket5

